import "@/utils/encryptStorage";
import App from "./App.vue";
import store from "./store";
import router from "./router";
import * as ElIcons from "@element-plus/icons-vue";
import * as filters from "@/utils/filters";
import { commonLayout, globalMessage, globalMessageBox } from "./components";
import customDirective from "@/directive/index";
import "./permission";
import "./polyfills";
import "./style/global.scss";
import "./style/common.scss";

// import Blob from './excel/Blob.js'
// import Export2Excel from './excel/Export2Excel.js'

const app = createApp(App);
app.use(store).use(router);
app.use(commonLayout);
app.use(globalMessage).use(globalMessageBox);
app.use(customDirective);
// 注册Icon组件
for (const name in ElIcons) {
  app.component(name, ElIcons[name]);
}

// // table无限滚动
// app.directive("tableInfiniteScroll", {
//   mounted(el, binding) {
//     let scrollTop = null;
//     let tbody = el.querySelector(".el-scrollbar__wrap");
//     let currentLimiting = false;
//     el.tableInfiniteScrollFn = function () {
//       scrollTop = this.scrollTop;

//       if (!currentLimiting) {
//         if (
//           this.scrollHeight - this.scrollTop - parseInt(this.style.height) <=
//           200
//         ) {
//           // debugger
//           currentLimiting = !currentLimiting;

//           binding.value(scrollTop);
//         }
//       }
//     };

//     tbody.scrollTop = scrollTop;
//     tbody.addEventListener("scroll", el.tableInfiniteScrollFn);
//     tbody = undefined;
//   },
//   unmounted(el) {
//     // debugger
//     let tbody = el.querySelector(".el-scrollbar__wrap");
//     tbody.removeEventListener("scorll", el.tableInfiniteScrollFn);
//     el.tableInfiniteScrollFn = undefined;
//   },
// });

app.config.globalProperties.$filters = { ...filters };
app.config.warnHandler = () => null;
app.mount("#app");
